import { _decorator, Component, Node, resources, Sprite, SpriteFrame } from 'cc';
import { Utils } from '../../utils/Utils';
const { ccclass, property } = _decorator;

@ccclass('headComp')
export class headComp extends Component {
    @property(Sprite)
    head!: Sprite;
    start() {

    }

    setHead(id: string) {
        let headurl = localStorage.getItem(id.toString()!)
        if (!headurl) {
            localStorage.setItem(id.toString()!, "textures/head/head" + Utils.randomInt(1, 6).toString() + "/spriteFrame")
            headurl = localStorage.getItem(id.toString()!)
        }
        let spr = resources.get(headurl!, SpriteFrame)!
        this.head.spriteFrame = spr
    }

    update(deltaTime: number) {

    }
}


